package yl.hs.bmipfull.controllers.dataCockpit;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.dataCockpit.IRawMaterialProcurementService;
import yl.hs.bmipfull.viewmodels.WebResult;

import java.text.ParseException;

/**
 * @author 韩纪旺
 * @apiNote
 * @since 2022/9/19 10:36 创建
 */
@Api(value = "数据驾驶舱-原材采购web接口", tags = "数据驾驶舱-原材采购")
@RestController
@RequestMapping(value = "/api/RawMaterialProcurement")
public class RawMaterialProcurementController extends ControllerBase {

    @Autowired
    IRawMaterialProcurementService  service;

    @ApiOperation(value = "原材采购--原材采购情况", notes = "原材采购情况")
    @RequestMapping(value = "ProcurementSituation/{timeType}",method = RequestMethod.GET)
    public WebResult completionRate(@ApiParam(value = "时间类型")@PathVariable String timeType) {

        return success( "查询成功",service.ProcurementSituation(timeType));
    }

    @ApiOperation(value = "原材采购--原材耗材情况", notes = "原材耗材情况")
    @RequestMapping(value = "Consumables/{timeType}",method = RequestMethod.GET)

    public WebResult consumables(@ApiParam(value = "时间类型")@PathVariable String timeType) {

        try {
            return success( "查询成功",service.consumables(timeType));
        } catch (Exception ee) {
            return error(ee);
        }
    }

    @ApiOperation(value = "原材采购--原材库存信息", notes = "原材库存信息")
    @RequestMapping(value = "RawMaterialsStock",method = RequestMethod.GET)
    public WebResult RawMaterialsStock() {
        return success("查询成功",service.RawMaterialsStock());
    }

    @ApiOperation(value = "原材采购--砂子价格趋势", notes = "砂子价格趋势")
    @RequestMapping(value = "sandPrice",method = RequestMethod.GET)
    public WebResult sandPrice() {
        try {
            return success("ok",service.getSandPrice());
        } catch (ParseException e) {
            return error(e);
        }
    }

    @ApiOperation(value = "原材采购--石料价格趋势", notes = "石料价格趋势")
    @RequestMapping(value = "stonePrice",method = RequestMethod.GET)
    public WebResult stonePrice() {
            try {
                return success("ok",service.getStonePrice());
            } catch (ParseException e) {
                return error(e);
            }
    }

    @ApiOperation(value = "原材采购--水泥价格趋势", notes = "水泥价格趋势")
    @RequestMapping(value = "cementPrice",method = RequestMethod.GET)
    public WebResult cementPrice() {
        try {
            return success("ok",service.getCementPrice());
        } catch (ParseException e) {
            return error(e);
        }
    }


}
